home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-15 | 2.3 KB | 108 lines | [TEXT/MMCC] |
- // ===========================================================================
- // SCPage.cp -- the page class
- // ===========================================================================
- // © 1995 James Kaput, Jeremy Roschelle SimCalc Project
-
- #include "SCPage.h"
- #include "SCDoc.h"
- #include "SCApp.h"
- #include "SCModelProperty.h"
-
- SCPage::SCPage(SCDoc *inDoc)
- {
- mModelKind = modelKind;
- mSuperModel = inDoc;
- inDoc->AddSubModel(this); // stores the page a list in the document
- mID = SCApp::GenerateUniqueID();
- *mName = 0;
- }
-
- SCPage::~SCPage()
- {
- mSuperModel->RemoveSubModel(this);
- mSuperModel = nil; // prevents LModelObject from doing removal
- }
-
- void
- SCPage::GetDescriptor(Str255 outName) const
- {
- CopyPStr(mName,outName);
- }
-
- Int32
- SCPage::GetID() const
- {
- return mID;
- }
-
- LModelObject*
- SCPage::GetModelProperty(DescType inProperty) const
- {
- return new SCModelProperty(inProperty, (SCPage *)this);
- }
-
- void
- SCPage::HandleAppleEvent(const AppleEvent &inAppleEvent,
- AppleEvent &outAEReply,
- AEDesc &outResult,
- Int32 inAENumber)
- {
- switch (inAENumber) {
- case ae_Select:
- ((SCDoc *)mSuperModel)->SetSelection(this);
- break;
- default:
- inherited::HandleAppleEvent(inAppleEvent,outAEReply,outResult,inAENumber);
- }
- }
-
- void
- SCPage::GetAEProperty(
- DescType inProperty,
- const AEDesc &inRequestedType,
- AEDesc &outPropertyDesc) const
- {
- long id, index;
- Str255 name;
-
- switch (inProperty) {
- case pIndex:
- index = mSuperModel->GetPositionOfSubModel(SCPage::modelKind, this);
- FailOSErr_(AECreateDesc(typeLongInteger, (Ptr) &index,
- sizeof(long), &outPropertyDesc));
- break;
- case 'ID ':
- id = GetID();
- FailOSErr_(AECreateDesc(typeLongInteger, (Ptr) &id,
- sizeof(long), &outPropertyDesc));
- break;
- case pName:
- GetDescriptor(name);
- FailOSErr_(AECreateDesc(typeChar, &(name[1]),
- name[0], &outPropertyDesc));
- break;
- default:
- inherited::GetAEProperty(inProperty,inRequestedType,outPropertyDesc);
- }
-
- }
-
- void
- SCPage::SetAEProperty(
- DescType inProperty,
- const AEDesc &inValue,
- AEDesc &outAEReply)
- {
- Str255 name;
-
- switch (inProperty) {
- case pName:
- UExtractFromAEDesc::ThePString(inValue,name);
- CopyPStr(name,mName);
- break;
- default:
- inherited::SetAEProperty(inProperty,inValue,outAEReply);
- }
-
- }
-